﻿using System;
using System.Collections.Generic;
using EscapeZone.Screens;
using EscapeZone.Serialization;

namespace EscapeZone.Mapping.Building
{
    public abstract class GenericBuilder<T> : IMapElementBuilder<T> where T : class, IDefinition
    {

        protected EscapeGame Game { get; private set; }
        protected GameScreen Screen { get; private set; }

        protected GenericBuilder(EscapeGame game, GameScreen gameScreen)
        {
            Game = game;
            Screen = gameScreen;
        }

        public abstract IDefinable BuildElement(T definition);

        public IMapElement Build(IDefinition definition)
        {
            T def = definition as T;
            if (def != null)
            {
                return BuildElement(def);
            }
            return null;
        }
    }
}